package com.allnas.jpa.service.impl;

import com.allnas.jpa.entity.User;
import com.allnas.jpa.repository.UserRepository;
import com.allnas.jpa.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhaojin
 */
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class UserServiceImpl implements UserService {

    private final UserRepository userRepository;

    @Override
    public void save(User user) {
        userRepository.save(user);
    }

    @Override
    public User findByUserName(String userName) {
        return userRepository.findByUserName(userName);
    }

    @Override
    public void deleteByAge(Integer age) {
        userRepository.deleteByAge(age);
    }
}
